#include <hardware/key/key.h>

unsigned int KEY_NUM = 0;

void INIT_KEY()
{
    pinMode(KEY, INPUT);
}

void LOOP_KEY()
{
    KEY_NUM = 0;
    // 软件消抖功能
    if (digitalRead(KEY) == LOW)
    {
        delay(10);
        if (digitalRead(KEY) == LOW)
        {
            KEY_NUM = 1;
            while (digitalRead(KEY) == LOW)
                ;
        }
    }
    if (KEY_NUM == 1)
    {
        relayState = relayState + 1;
    }
    if (relayState >= 2)
    {
        relayState = 0;
    }
}
